package com.chenjun.web.controller.oa;

import java.util.Arrays;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.chenjun.common.base.ResultDto;
import com.chenjun.common.bean.Pagination;
import com.chenjun.common.model.DataGridModel;
import com.chenjun.common.model.DataGridSortModel;
import com.chenjun.core.service.oa.OaBillAttnDayReportService;
import com.chenjun.core.service.oa.OaBillAttnDetailService;

/**
 * @Description: 异常打卡处理
 * @author dongyibin
 * @date 2017-8-20 下午1:47:55
 */
@Controller
@SuppressWarnings("serial")
@RequestMapping("abnormalClock")
public class AbnormalClockController {
	@Autowired
	private OaBillAttnDetailService oaBillAttnDetailService;
	@Autowired
	private OaBillAttnDayReportService oaBillAttnDayReportService;

	@RequestMapping("/list.html")
	public String index() {
		return "exceptionAttendance/abnormalClock";
	}
	
	/**
	 * 标准、非标准、综合：打卡次数等于1为异常 
	 * 非标准：打卡间隔超过8小时为异常
	 * 
	 * @Description:获取异常打卡信息
	 * @param request
	 * @return
	 * @author dongyibin
	 * @date 2017-8-27 下午2:12:31
	 */
	@RequestMapping("/search")
	@ResponseBody
	public ResultDto getAbnormalClock(HttpServletRequest request, DataGridModel model) {
		ResultDto rtDto = new ResultDto();
		String ids= model.getParams().get("userIds").toString();
		model.getParams().put("userIds", Arrays.asList(ids.split(","))); 
		model.getSortBy().add(new DataGridSortModel("clock_time", DataGridSortModel.DESC));
		Pagination data = oaBillAttnDetailService.getAbNormalClock(model);
		rtDto.setData(data);
		return rtDto;
	}
}
